/**
 * @description 页面分页
 */
export default {
	data() {
		return {
			rbdStatus: false,
			rbdOption: {
				value: [
					{},
					{},
					{},
					{},
					{},
					{},
					{},
					{},
					{},
					{}
				],
				page: 1,
				pageSize: 20,
				totalPage: 1
			},
		}
	},
	onReachBottom() {
		!this.rbdReachBottom && this.rbdLoadingFn();
	},
	methods: {
		// 加载数据
		async rbdLoadingFn() {
			let {
				value,
				page,
				pageSize,
				totalPage
			} = this.rbdOption;
			if (page > totalPage) return false;
			if (page==1) value = [];
			if (this.rbdReqeust) {
				let res = await this.rbdReqeust({
					page: page - 1,
					pageSize
				});
				this.rbdStatus = true;
				if (res.code === 0) {
					let {
						list,
						total
					} = res.data;
					this.rbdOption = {
						value: value.concat(list),
						page: ++page,
						pageSize,
						totalPage: Math.ceil(total / pageSize)
					}
				}
			}
		},
		// 刷新数据
		rbdRefreshFn() {
			this.rbdOption = this.$options.data().rbdOption;
			this.rbdLoadingFn();
		}
	}
}